package com.ruoyi.yl.rocketmq.listern;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;



/**
 * 死信队列 兜底服务
 */
@RocketMQMessageListener(
    topic = "%DLQ%my-consumer-group", // 死信队列前缀
    consumerGroup = "dlq-group"
)
@Slf4j
public class DLQConsumer implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        //发送邮件 等操作
        JSONObject jsonObject = JSON.parseObject(messageExt.getBody());
        log.error("DLQConsumer:{}", JSON.toJSONString(jsonObject));

    }
}
